package com.seventeen.monster.redisson.support;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Objects;

/**
 * @author seventeen
 */
public class LockExpressionRoot {

    private final Method method;

    private final Object[] args;

    private final Object target;

    private final Class<?> targetClass;

    public LockExpressionRoot(Method method, Object[] args, Object target, Class<?> targetClass) {
        this.method = method;
        if (Objects.nonNull(args)){
            this.args = Arrays.copyOf(args,args.length);
        } else {
            this.args = new Object[0];
        }
        this.target = target;
        this.targetClass = targetClass;
    }

    public Method getMethod() {
        return this.method;
    }

    public String getMethodName() {
        return this.method.getName();
    }

    public Object[] getArgs() {
        if (Objects.nonNull(this.args)){
            return Arrays.copyOf(this.args,this.args.length);
        } else {
            return new Object[0];
        }
    }

    public Object getTarget() {
        return this.target;
    }

    public Class<?> getTargetClass() {
        return this.targetClass;
    }
}